/**
 * 发票申请确认对话框（可用于添加和修改对话框）
 */
var InvoiceSubmitDlg = {
    width: '680px',
    height: 'auto',
    currentLayerIndex: -1,
    cache: ""
};

/**
 * 初始化新增弹出框
 */
InvoiceSubmitDlg.init = function () {
    this.cache = $("#invoiceSubmitDlg").html();
    $("#invoiceSubmitDlg").html('');
};

/**
 * 关闭此对话框
 */
InvoiceSubmitDlg.close = function () {
    layer.close(this.currentLayerIndex);
};

/**
 * 打开模态框调用事件
 * 初始化
 */
InvoiceSubmitDlg.renderAdd = function () {
    //初始化

};


/**
 * 发票申请作废
 */
InvoiceSubmitDlg.cancelInvoice = function (id) {
    var ajax = new $ax(Feng.ctxPath + "/invoice/cancelInvoice", function (data) {
        Feng.log("发票申请作废申请成功");
        if (data.success) {
            Feng.success("操作成功！");
        } else if (data.code === "2") {
            Feng.error(data.msg);
        } else {
            Feng.error("操作失败!");
        }
    }, function (data) {
        Feng.error("加载信息失败!");
    });
    ajax.data = {id: id};
    ajax.start();
};

/**
 * 发票申请信息
 */
InvoiceSubmitDlg.invoiceInfo = function (row) {
    $("#tax_number").val(row.taxNumber);
    $("#invoice_title").html(row.invoiceTitle);
    $("#invoiced_compamy").val(row.invoicedCompamy);
};

/**
 * 发票申请确认提交
 */
InvoiceSubmitDlg.invoiceSubmit = function (uid) {
    var option = {
        id : uid,
        taxNumber: $("#tax_number").val(),
        invoicedCompamy: $("#invoiced_compamy").val()
    };
    var ajax = new $ax(Feng.ctxPath + "/invoice/submitInvoice", function (data) {
        Feng.log("发票申请确认成功");
        if (data.success) {
            Feng.success("操作成功");
            InvoiceTable.me.refresh();
        } else if (data.code === 2) {
            Feng.error(data.msg);
        } else {
            Feng.error("操作失败!");
        }
    }, function (data) {
        Feng.error("加载信息失败!");
    });
    ajax.setData(option);
    ajax.start();
};
